package org.unidbfw.gui;

import java.awt.BorderLayout;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JMenuBar;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JLabel;

import org.unidbfw.application.IApplication;

public class MainWindow extends JFrame implements MainWindowConst
{

	private static final long serialVersionUID = -5425210862273882506L;
	private JPanel contentPane;
	private static final MainWindow inst = new MainWindow();
	
	private MainWindow()
	{
		updateTitle();
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 450, 300);
		
		
		JMenuBar menuBar = new JMenuBar();
		setJMenuBar(menuBar);
		
		JMenu mnCommand = new JMenu("Command");
		menuBar.add(mnCommand);
		
		JMenuItem mntmConnect = new JMenuItem("Connect");
		mnCommand.add(mntmConnect);
		
		JMenuItem mntmLogin = new JMenuItem("Login");
		mnCommand.add(mntmLogin);
		
		JMenuItem mntmExit = new JMenuItem("Exit");
		mnCommand.add(mntmExit);
		
		JMenu mnView = new JMenu("View");
		menuBar.add(mnView);
		
		JMenuItem mntmTables = new JMenuItem("Tables");
		mnView.add(mntmTables);
		
		JMenuItem mntmViews = new JMenuItem("Views");
		mnView.add(mntmViews);
		
		JMenuItem mntmQueries = new JMenuItem("Queries");
		mnView.add(mntmQueries);
		
		JMenu mnHelp = new JMenu("Help");
		menuBar.add(mnHelp);
		
		JMenuItem mntmAbout = new JMenuItem("About...");
		mnHelp.add(mntmAbout);
		
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		contentPane.setLayout(new BorderLayout(0, 0));
		setContentPane(contentPane);
	}
	
	public static MainWindow getInst()
	{
		return inst;
	}
	
	public void setState(String state)
	{
		
	}
	
	private void updateTitle()
	{
		StringBuilder sb = new StringBuilder();
		sb.append(WINDOW_TITLE + IApplication.APPLICATION_VERSION);
		sb.append(" - ");
		sb.append(WINDOW_USER);
		sb.append(" ");
		sb.append(WINDOW_ROLE);
		setTitle(sb.toString());
	}
	
}
